﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Linq;
using MS.InformationManagement.DAL.DocumentCenter;

namespace MS.InformationManagement.Controls._CONTROLTEMPLATES.InformationManagerControls
{
    public partial class IntialRadicadoTypeSelector : UserControl
    {

        #region Properties

        public string SelectedInitialType { get { return chkInitialTypeSelector.SelectedItem == null ? string.Empty : chkInitialTypeSelector.SelectedItem.Text.Replace(" ", string.Empty); } }

        public TipificaciónInicial SelectedTipificaciónInicial { get { return getTipificaciónInicial(); } }
        
        #endregion

        #region Form events

        protected void Page_Load(object sender, EventArgs e)
        {
            chkInitialTypeSelector.Attributes.Add("onclick", "return HandleOnCheck()");
        }

        #endregion

        #region Public Methods

        public void SetInitialValue(string selectedValue)
        {
            chkInitialTypeSelector.SelectedIndex = chkInitialTypeSelector.Items.IndexOf((from item in chkInitialTypeSelector.Items.OfType<ListItem>()
                                                                                         where item.Text == selectedValue
                                                                                         select item).FirstOrDefault());
        }

        public TipificaciónInicial getTipificaciónInicial()
        {
            return (TipificaciónInicial)Enum.Parse(typeof(TipificaciónInicial), chkInitialTypeSelector.SelectedItem.Value);
        }

        #endregion

    }
}
